package cn.com.jtang.wedding.action;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;

import cn.com.jtang.wedding.model.AdminUser;
import cn.com.jtang.wedding.model.User;

import com.opensymphony.xwork2.ActionSupport;

public class BaseAction extends ActionSupport{
	
	private transient final Log logger = LogFactory.getLog(getClass());
	
	protected int pageNum;
	protected int pageSize = 3;
	protected int pageCount;
	
	
    protected HttpServletRequest getRequest() {
        return ServletActionContext.getRequest();
    }

    protected HttpServletResponse getResponse() {
        return ServletActionContext.getResponse();
    }
    
    protected HttpSession getSession() {
        return getRequest().getSession();
    }
    
    protected AdminUser getCurrentAdminUser() {
    	HttpSession session = getRequest().getSession();
        Object object = session.getValue("currentadminuser");
        if(object == null){
        	return null;
        }
        return (AdminUser)object;
    }
    
    protected User getCurrentUser() {
        HttpSession session = getRequest().getSession();
        Object object = session.getValue("currentuser");
        if(object == null){
        	return null;
        }
        return (User)object;
    }

    
	
	
	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}


	public int getPageSize() {
		return pageSize;
	}


	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageCount() {
		return pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public int getNextPage() {
		return pageNum + 1;
	}

	public int getBackPage() {
		return pageNum - 1;
	}
    
}

